package com.wc._16届国特冲刺营._05动态规划_状态压缩黑科技.羊圈;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2025/5/9 16:37
 * @description
 * https://www.lanqiao.cn/courses/51805/learning/?id=4072909&compatibility=false
 */
public class Main {
    /**
     * 思路：
     * 旅行商问题
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 210, M = 1 << 15;
    static double[][] f = new double[N][M];
    static int[] a = new int[N];
    static double[] p = new double[N];
    static int n, m;

    public static void main(String[] args) {
        m = sc.nextInt();
        n = sc.nextInt();
        for (int i = 0; i < m; i++) a[i] = sc.nextInt();
        for (int i = 1; i <= n; i++) p[i] = sc.nextDouble();
        for (int i = 1; i <= n; i++) Arrays.fill(f[i], n + 1);

        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < 1 << m; j++) {
                // 第 i 个羊不会圈起来
                f[i][j] = f[i - 1][j] + p[i];
                for (int k = 0; k < m; k++) {
                    if ((j >> k & 1) == 1) f[i][j] = Math.min(f[i][j], f[Math.max(0, i - a[k])][j - (1 << k)]);
                }
            }
        }
        out.printf("%.2f", f[n][(1 << m) - 1]);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

